<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>参与单位详细信息</title>
<%@ include file="/common/meta.jsp"%>
<script type="text/javascript" src="${res}/js/proposal/irisPrpPrepare.js"></script>
<script type="text/javascript" src="${res}/js/validate/irisvalidator.js"></script>
<script type="text/javascript" src="${res}/js/autodisckey/autodisckey.js"></script>

<style type="text/css">
	.input_width { width:130px }
	.select_width { width:143px }
	.table_td td {border:0}
	.long_input{ width:642px }
    .selectWidth4{width:624px;}
</style>
<script type="text/javascript">
var type = "${param.type}";
var parentTable = parent.$("#"+"${param.parentTab}");	//父页面的表格
var selectRadio = $();									//父页面选中的单选框
var selectTr = $();										//父页面选中的行

if(type=="edit") {
	selectRadio = parentTable.find(":radio:checked");
	selectTr = selectRadio.parents("tr");
}

$(function(){
//	$("#fragment-tab1 :text,#fragment-tab1 [type='date']").addClass("input_width");
	//$("#fragment-tab1 select").addClass("select_width");
	
	if(type=="edit"){
		
		$("input:not(:radio:button),textarea").each(function(){

			var id=$(this).attr("name");
			if(id==null || id=="")
				return true;
			
			var parentObj=selectTr.find("[name$='/"+id+"']");
			var value="";
			if(parentObj.is("span"))
				value=parentObj.text();
			else
				value=parentObj.val();
			//if($(this).is("input"))//初始化input框 不包括radio
				$(this).val(value);
		});
		
		$(":radio").each(function(){//初始化radio框
			var name=$(this).attr("name");
		
			
			var value=$("[name='"+name+"_value']").val();
			if($(this).val()==value)
				$(this).attr("checked",true);
			
		});
		tree();
	}
	
	 function savePsn(){
		//填写检查接口
		validate($("#fragment-tab1"),"");
		if(!valResult()){
			irisValShowMsg($("#savePsn"));
			return false;
		}
		
		
		
		
		//添加新行
		if(type=="add") {
			addNewRowDeal(parentTable);
		}
		$("textarea").each(
				function() {
					var val = $(this).val();
					val = val.replace(/&/g, "&amp;").replace(/</g, "&lt;")
							.replace(/>/g, "&gt;").replace(/\n/g, "<br/>")
							.replace(/\s/g, "&nbsp;").replace(/"/g, "&quot;");
					$("input[name='" + $(this).attr('name') + "_hidden']").val(
							val);
				});
		$("input:not(:radio:button),textarea").each(function(){
			
			var id=$(this).attr("name");
			var parentObj=null;
			
			if(id==null || id=="")
				return true;
			
			//获得父页面的对象
			if(type=="add"){
				parentObj=parentTable.find("tr:last-child").find("[name$='/"+id+"']");
			}else if(type=="edit"){
				parentObj=selectTr.find("[name$='/"+id+"']");
				
			}

			if(parentObj!=null){
				if(parentObj.is("span")){
					parentObj.text($(this).val());	//将值写回父页面
				}
				else{
					parentObj.val($(this).val());
				}
			}
		});
		
		if(type=="add"){
			parentTable.find("tr:last :radio").attr("checked",true);
		}
		
		
		//if(confirm("保存成功，是否返回申请书页面"))
		//	parent.tb_remove();
		//else
		$(".wBox_popup").hide();
		if(confirm("保存成功，是否返回申请书页面")){
			parent.tb_remove();
		}
			
		else if(type=="add"){
			type = "edit";
			selectRadio = parentTable.find(":radio:checked");	//父页面选中的单选框
			selectTr = selectRadio.parents("tr");				//父页面选中的行
		}
	}
	$("#savePsn").click(function(){
		setTimeout(savePsn,100);
	}); 
});
function tree(){
	/* var org_type_name = $("#org_type_name").val(); 
	$("#org_type").val(org_type_name); */
	
	var principle_prof_title_name = $("#principle_prof_title_name").val(); 
	$("#principle_prof_title").val(principle_prof_title_name);
	
	var contact_prof_title_name = $("#contact_prof_title_name").val(); 
	$("#contact_prof_title").val(contact_prof_title_name);
	
}

function loadAjaxSelect(selectId,url,params,varParm){
	$.ajax( {
		url : url,
		type : 'post',
		dataType:'json',
		data : params,
		success : function(data) {
			
			for(var i=0;i<data.length;i++){
				var value=data[i].id;
				var text=data[i].name;		
				$("#"+selectId).append("<option value='"+value+"'>"+text+"</option>");
				

			}
			if(type=="edit"){//如果是修改，才需要初始化select框的值
				var selectValue=$("[name='"+selectId+"_value']").val();
				$("#"+selectId+" option").each(function(i,obj){
					if($(obj).val()==selectValue){
						setTimeout(function() {
							$(obj).attr("selected",true);
						}, 1);
					}
				});
			}
		}
	});
	}




</script>
<script type="text/javascript">
function initTreeValueExt(treeId, treeNode) {
	   
	 if (!(treeNode && (treeNode.level > 0 || !treeNode.isParent))) {
		  scmWarn("请选择具体的"+$("#" + treeId).attr("label"));
		if (treeNode.level == 0) {
			$("#" + treeId).val("");
			$("#" + treeId).parents("td").find("[name$='" + treeId + "_code'],[id$='" + treeId+ "_code']").val("");
			$("#" + treeId).parents("td").find("[name$='" + treeId + "_value'],[id$='" + treeId+ "_value']").val("");
			$("#" + treeId).parents("td").find("[name$='" + treeId + "_name'],[id$='" + treeId+ "_name']").val("");
		}
		
		return false;
		}
		var str = treeNode.name;
		var obj = treeNode.parentNode;
		while (obj != null) {
			obj = obj.parentNode;
		}
		
		$("#" + treeId).parents("td").find("[name$='" + treeId + "_code'],[id$='" + treeId+ "_code']").val(treeNode.id);
		$("#" + treeId).parents("td").find("[name$='" + treeId + "_value'],[id$='" + treeId+ "_value']").val(treeNode.id);
		$("#" + treeId).parents("td").find("[name$='" + treeId + "_name'],[id$='" + treeId+ "_name']").val(str);
		
	}
/**
 * 各类公用控件和radio框储存值到隐藏域中(除了tree和智能下拉框外)
 */
function initControlValue(objId){
	
		var name="";
		var obj=$("#"+objId);
	    if(obj.is("select")){
	    	name=obj.attr("name");
	    	obj.parent().children("input[name$='"+name+"_value'][type='hidden']").val($("#"+objId).find("option:selected").val());
	    	$("#"+objId).parent().children("input[name$='"+name+"_name']").val($("#"+objId).find("option:selected").text());
	    }
	   
	    else if(obj.is(":radio")){
	    	name=obj.attr("name");
	    	if(obj.is(":checked")){//如果被选中
	    		//alert($("#"+objId).val());		
	    		obj.parents("table").find("input[name$='"+name+"_value'][type='hidden']").val($("#"+objId).val());
	    		$("#"+objId).parent().children("input[name$='"+name+"_name']").val($("#"+objId).next().text());
	    	}
	    	else{
	    		
	    		obj.parents("table").find("input[name$='"+name+"_value'][type='hidden']").val("");
	    	}
	    }else if(obj.is(":checkbox")){
	    	name=obj.attr("name");
	    	if(obj.is(":checked"))//如果被选中
	    		obj.parent().find("input[name$='"+name+"_value'][type='hidden']").val($("#"+objId).val());
	    	else
	    		obj.parent().find("input[name$='"+name+"_value'][type='hidden']").val("");
	    }else{
	    	name=obj.attr("id");
	    	obj.parents("td").find("input[name$='"+name+"_name'][type='hidden']").val(obj.val());
	    	obj.parents("td").find("input[name$='"+name+"_code'][type='hidden']").val($("#"+objId+"_hideId").val());
	    }  	
}
function addNewRowDeal(table)
{
	var maxLinNum=table.find("tr").length-2;;//获得行数，减去表头和隐藏行
	var lineNum=""+(maxLinNum+1);
	var addHtml=table.find("tr")[1].innerHTML;//获得隐藏行的html,查找第二行
	addHtml=addHtml.replace(/\[index\]/g,lineNum);
	lineNum = (parseInt(lineNum, 10)-1).toString();//2011.12.13 行下标比行号小1(隐藏行下标[0]，第一行下标[00])
	if (lineNum.length==1)//如果是个位数，前面补0
		lineNum="0"+lineNum;
	addHtml=addHtml.replace(/\[0\]/g,"["+lineNum+"]");//替换html中行号
	addHtml=addHtml.replace(/\|/g,"/");//替换html中节点/的代替符"|"
	table.append("<tr>"+addHtml+"</tr>");//将html增加到最后
	/*
	table.find("tr:last").find(":text,textarea,select").not(":hidden").each(function(){
		var objClass=$(this).attr("class");
		if(objClass==null){
			objClass="required";
		}
		else if(objClass.indexOf("nvalidate")>=0){
			
		}
		else if(objClass!=null&&objClass.indexOf("required")==-1){
			objClass=objClass+" required";
		} 
		$(this).attr("class",objClass);//给所有行的列加上必填检查
	});
	*/
	//reDealRow(tbl);
}
</script>
</head>
<body>

	<div id="tabnav">
		<ul>
			<li class="down" id="tab1" onclick="changeTab(this.id)">
					<a href="###"><span>股东单位情况</span></a>
			</li>
		</ul>
	</div>
	
	<div class="tab_box" id="fragment-tab1">
		<table class="t_css table01" width="100%" border="0" cellpadding="0" label="股东单位情况" cellspacing="1">
		<col style="width:15%" />
		<col style="width:35%" />
		<col style="width:15%" />
		<col style="width:35%" />
		

		<tr class="li_1">
		<td align="right" ><span  class="color_red">*</span>单位名称：</td>
		<td colspan="3">
		<input id="org_name1"  name="cname"  label="单位名称" type="text"  class="required input_css  maxlength:100"  style="width:92%;" maxlength="100" value=""/> 
		    
		</td>
	</tr>
	<tr  class="li_2">
		<td align="right" ><span  class="color_red">*</span>地址：</td>
		<td colspan="3"><input  name="address"   label="地址" type="text"  class="required input_css  maxlength:100"  style="width:92%;" maxlength="100" value=""/> 
		</td>
	</tr>
	
	
	<tr  class="li_1">
		<td align="right" ><span  class="color_red">*</span>单位类型：</td>
	 <%--  <td colspan="3">
			<cpt:tree key="org_type" cacheable="false" readonly="true" value="" id="org_type" name="org_type"  showPattern="all" shieldPattern="-1" onClick="initTreeValueExt"   label="单位类型" />
			<input type="hidden" id="org_type_value" name="org_type_value" value="" class="required"  label="单位类型"/> 
			<input type="hidden" id="org_type_name" name="org_type_name" value="" />
		</td> --%>
		
		<td colspan="3">
				<cpt:select id="org_type"  key="org_type" onChange="initControlValue(this.id)" style="width:34%"></cpt:select>
				<input type="hidden" name="org_type_value" value=""  class="required"  label="单位类型"/>
				<input type="hidden" name="org_type_name" value="" />
			</td>
		
		
		
		
		
	</tr>
	
	<tr  class="li_2">
		<td align="right" ><span  class="color_red">*</span>归属地：</td>
		<td colspan=""><input  name="bolonging_area"   label="归属地" type="text"  class="required input_css  maxlength:100"  style="width:80%;" maxlength="100" value=""/> 
		</td>
		<td align="right" ><span  class="color_red">*</span>法人代表：</td>
		<td colspan=""><input  name="corporate_representative"   label="法人代表" type="text"  class="required input_css  maxlength:100"  style="width:80%;" maxlength="100" value=""/> 
		</td>
	</tr>
	
	
	<tr  class="li_1">
		<td align="right" ><span  class="color_red">*</span>管理负责人：</td>
		<td colspan="3"><input  name="principle_name"   label="管理负责人" type="text"  class="required input_css  maxlength:100"  style="width:240px;" maxlength="100" value=""/> 
		</td>
	</tr>
	
	<tr  class="li_2">
		<td align="right" ><span  class="color_red">*</span>职称：</td>
		<td>
			<cpt:tree key="prof_title" cacheable="false" readonly="true" value="" id="principle_prof_title" name="principle_prof_title"  showPattern="all" shieldPattern="-1" onClick="initTreeValueExt"   label="管理负责人职称" />
			<input type="hidden" id="principle_prof_title_value" name="principle_prof_title_value" value="" class="required"  label="管理负责人职称"/> 
			<input type="hidden" id="principle_prof_title_name" name="principle_prof_title_name" value="" />
		</td>
    <td align="right" ><span  class="color_red">*</span>职务：</td>
		<td colspan=""><input  name="principle_position"   label="管理负责人职务" type="text"  class="required input_css  maxlength:100"  style="width:80%;" maxlength="100" value=""/> 
		</td>
	</tr>
	
	<tr  class="li_1">
		<td align="right" ><span  class="color_red">*</span>移动电话：</td>
		<td colspan=""><input  name="principle_mobile"   label="管理负责人移动电话" type="text"  class="required input_css  maxlength:11 mobile"  style="width:80%;" maxlength="100" value=""/> 
		</td>
		<td align="right" ><span  class="color_red">*</span>电子信箱：</td>
		<td colspan=""><input  name="principle_email"   label="管理负责人电子信箱" type="text"  class="required input_css  maxlength:100 email"  style="width:80%;" maxlength="100" value=""/> 
		</td>
	</tr>
	
	
	
	
	<tr  class="li_2">
		<td align="right" ><span  class="color_red">*</span>联系人：</td>
		<td colspan="3"><input  name="contact_name"   label="联系人" type="text"  class="required input_css  maxlength:100"  style="width:240px;" maxlength="100" value=""/> 
		</td>
	</tr>
	
	<tr  class="li_1">
		<td align="right" ><span  class="color_red">*</span>职称：</td>
		<td>
			<cpt:tree key="prof_title" cacheable="false" readonly="true" value="" id="contact_prof_title" name="contact_prof_title"  showPattern="all" shieldPattern="-1" onClick="initTreeValueExt"   label="联系人职称" />
			<input type="hidden" id="contact_prof_title_value" name="contact_prof_title_value" value="" class="required"  label="联系人职称"/> 
			<input type="hidden" id="contact_prof_title_name" name="contact_prof_title_name" value="" />
		</td>
		<td align="right" ><span  class="color_red">*</span>职务：</td>
		<td colspan=""><input  name="contact_position"   label="联系人职务" type="text"  class="required input_css  maxlength:100"  style="width:80%;" maxlength="100" value=""/> 
		</td>
	</tr>
	
	<tr  class="li_2">
		<td align="right" ><span  class="color_red">*</span>移动电话：</td>
		<td colspan=""><input  name="contact_mobile"   label="联系人移动电话" type="text"  class="required input_css  maxlength:11 mobile"  style="width:80%;" maxlength="100" value=""/> 
		</td>
		<td align="right" ><span  class="color_red">*</span>电子信箱：</td>
		<td colspan=""><input  name="contact_email"   label="联系人电子信箱" type="text"  class="required input_css  maxlength:100 email"  style="width:80%;" maxlength="100" value=""/> 
		</td>
	</tr>
	
	
	
	
	
	
	
	
	<%-- <tr  class="li_1">
		<td  align="right"><span  class="color_red">*</span>注册类型：</td>
		<td  align="left" colspan="2">
		<cpt:tree key="nature_type" cacheable="false" className="hn_iuput_kuang gray" readonly="true" value="" label="注册类型"
			id="nature"  showPattern="current" shieldPattern="0" topCheckbox="false" onClick="initTreeValueExt" /> 
		<input type="hidden" id="nature_code" name="nature_code" class="required " label="注册类型" value="" /> 
		<input type="hidden" id="nature_name" name="nature_name" value="" /></td>
		<td align="right"><span  class="color_red">*</span>组织机构代码：</td>
		<td><input name="org_no"  label="组织机构代码" type="text" class="required input_css orgCard " maxlength="20" value="" /></td>
	</tr>
	<tr   class="li_2">
		<td align="right"><span  class="color_red">*</span>项目联系人：</td>
		<td  colspan="2">
			<input name="contact_psn_name"  label="项目联系人" type="text" class="required input_css " maxlength="30" value="" /></td>
		<td align="right"><span  class="color_red">*</span>电话：</td>
		<td><input name="contact_psn_tel"  label="电话" type="text" class="required input_css " maxlength="30" value="" /></td>
	</tr>
	<tr   class="li_1">
		<td align="right"><span  class="color_red">*</span>Email地址：</td>
		<td  colspan="2">
			<input name="email"  label="Email地址" type="text" class="required input_css email" maxlength="50" value="" /></td>
		<td align="right"><span  class="color_red">*</span>手机：</td>
		<td><input name="mobile"  label="手机" type="text" class="required input_css mobile" maxlength="11" value="" /></td>
	</tr>
	<tr  class="li_2">
		<td  align="right" ><span  class="color_red">*</span>工作分工（限200字）：</td>
        <td colspan="4">
			<textarea rows="4" style="width:98%;"   class="required input_textarea   maxlength:200"   name='work_divide'  label="工作分工"></textarea>
		   <input type='hidden' name='work_divide_hidden' id='work_divide_hidden' value=''>
		  </td>
	</tr>
	<tr  class="li_1">
		<td  align="right" >经费预算分配情况：</td>
		<td  align="right" ><span  class="color_red">*</span>总经费（万元）：</td>
        <td colspan="1">
			<input  name="fund_all"   label="经费预算分配情况中的总经费" type="text"  class="required input_css " style="text-align: right;" onfocus="InitInput.setNumber(this,7,2,2)" value=""/>
		</td>
		<td  align="right" ><span  class="color_red">*</span>省财政经费（万元）：</td>
        <td colspan="1">
			<input  name="province_fund"  label="经费预算分配情况中的省财政经费" type="text"  class="required input_css " style="text-align: right;" onfocus="InitInput.setNumber(this,7,2,2)" value=""/>
		</td>
	  </tr> --%>
	</table>
	</div>

	<table width="100%" align="center">
		<tr>
			<td><input type="button"  class="button_01 notdisabled" id="savePsn" value="保存">
				&nbsp;<input type="button" id="cancel" class="button_01 notdisabled" value="取消" onclick="parent.tb_remove();">
			</td>
		</tr>
	</table>
	<br />
</body>
</html>